﻿using MediatR;
using T_Person.APi.Applation.CommandHandlers.EmployeeHandlers;
using T_Person.BaseRep.Interface;

namespace T_Person.APi.Applation.Commands.EmployeeCommand
{
    public class EmployeeUpdateBynameCommand : IRequestHandler<EmployeeUpdateByNameHandlers, int>
    {
        private readonly IEmployeeRep  employeeRep;

        public EmployeeUpdateBynameCommand(IEmployeeRep employeeRep)
        {
            this.employeeRep = employeeRep;
        }

        public async Task<int> Handle(EmployeeUpdateByNameHandlers request, CancellationToken cancellationToken)
        {
            var list = await employeeRep.GetAloneByresult(x => x.Ename == request.name);
            list.AuditState = 1;
            list.UpdateDate = DateTime.Now;
            list.UpdateBy = "小红";
            return await employeeRep.Update(list);
        }
    }
}
